# Specify the minimum required version of CMake
cmake_minimum_required(VERSION 3.10)

# Set the project name and version (optional: C/CXX)
project(VideoStream VERSION 0.1 LANGUAGES C CXX)

include_directories(${CMAKE_SOURCE_DIR}/include)
link_directories(${CMAKE_SOURCE_DIR}/lib)

set(PYTHON_INCLUDE_DIRS 
    /home/marvsmart/miniconda3/envs/sg/include/python3.10
    /home/marvsmart/miniconda3/envs/sg/lib/python3.10/site-packages/numpy/core/include
    )
include_directories(${PYTHON_INCLUDE_DIRS})
link_directories(/home/marvsmart/miniconda3/envs/sg/lib/python3.10/config-3.10-aarch64-linux-gnu)


set(ONNX_INCLUDE_DIRS /home/marvsmart/workspace/jumping-exam-rk3588/include/onnxruntime)
include_directories(${ONNX_INCLUDE_DIRS})




set(PYTHON_LIBRARIES /home/marvsmart/miniconda3/envs/sg/lib/libpython3.10.so)


set(SRC_DIR ${PROJECT_SOURCE_DIR}/src)

set(SRC_FILES 
    ${SRC_DIR}/onnx_caller.cpp
    # ${SRC_DIR}/python_caller.cpp
    ${SRC_DIR}/mq_msg.cpp
    ${SRC_DIR}/http_server.cpp 
    ${SRC_DIR}/rtmp_pusher.cpp 
    ${SRC_DIR}/tmprtmp.cpp 
    ${SRC_DIR}/process_frame.cpp 
    ${SRC_DIR}/main.cpp 
    )

set(CMAKE_CXX_FLAGS "-std=c++14")

# Add libraries (if needed)
# target_link_libraries(video_stream PRIVATE some_library)

# Include directories (for headers)


# 寻找FFmpeg组件
find_package(PkgConfig REQUIRED)
pkg_check_modules(AVCODEC REQUIRED libavcodec)
pkg_check_modules(AVFORMAT REQUIRED libavformat)
pkg_check_modules(AVUTIL REQUIRED libavutil)
pkg_check_modules(SWSCALE REQUIRED libswscale)
pkg_check_modules(AVFILTER REQUIRED libavfilter)
pkg_check_modules(AVDEVICE REQUIRED libavdevice )

# 查找OpenCV库
find_package(OpenCV REQUIRED)
# 包含OpenCV的头文件路径
include_directories(${OpenCV_INCLUDE_DIRS})

# 查找jsoncpp库
find_package(jsoncpp REQUIRED)
# 包含jsoncpp的头文件路径
include_directories("/usr/include/jsoncpp")
message(STATUS "${JSONCPP_INCLUDE_DIRS}")

# Add an executable target (compiles a source file into a binary)
add_executable(video_stream ${SRC_FILES})

target_link_libraries(video_stream rt)
target_link_libraries(video_stream onnxruntime)
target_link_libraries(video_stream ${PYTHON_LIBRARIES})
target_link_libraries(video_stream caca ncurses ffi ncursesw)
target_link_libraries(video_stream pthread jsoncpp ${OpenCV_LIBS} ${AVCODEC_LIBRARIES} ${AVFORMAT_LIBRARIES} ${AVUTIL_LIBRARIES} ${SWSCALE_LIBRARIES} ${AVFILTER_LIBRARIES} ${AVDEVICE_LIBRARIES})